﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DingY.DB;

namespace DotNet.WinUI.Admin
{
    public partial class FrmLogin : BaseForm
    {
        public FrmLogin()
        {
            InitializeComponent();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        public string _LoginID;

        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtLoginID.Text) || string.IsNullOrEmpty(txtPwd.Text))
            {
                ShowMsg("用户代码或用户密码不允许为空！");
                return;
            }
            string _Sql = @"SELECT COUNT(*) 
                FROM Users
                WHERE LoginID = '{0}'
	                and Pwd ='{1}' ";
            _Sql = string.Format(_Sql,
                txtLoginID.Text,
                txtPwd.Text);

            SqlDB objSqlDB = new SqlDB();
            if (Convert.ToInt32(objSqlDB.ExecuteScalar(_Sql)) >= 1)
            {
                _LoginID = txtLoginID.Text;
                Close();
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            else
            {
                ShowMsg("用户代码和用户密码不正确？");
            }
        }
    }
}